home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-07 | 5.4 KB | 234 lines | [TEXT/KAHL] |
- /*****
- * CNeoDemoApp.c
- *
- * Application methods for a typical application.
- *
- * Copyright © 1992 NeoLogic Systems. All rights reserved.
- *
- *****/
-
- #include "NeoTypes.h"
- #include CNeoMetaClassH
- #include <Commands.h>
- #include <CDesktop.h>
- #include <CBartender.h>
- #include <CWindow.h>
- #include <CList.h>
- #include "CNeoDLOGDialog.h"
- #include "CNeoDemoDoc.h"
- #include "CNeoDemoApp.h"
- #include "CNDCamera.h"
- #include "CNDImagePICT.h"
- #include "CNDImageTIFF.h"
- #include "CNDImageGIF.h"
-
- extern OSType gSignature;
-
- extern CDesktop *gDesktop; // The visible Desktop
- extern CBartender *gBartender; // Manages all menus
-
- int main(void)
- {
- CNeoDemoApp * app;
-
- app = new CNeoDemoApp();
- app->Run();
- app->Exit();
-
- return 0;
- }
-
- /***
- * CNeoDemoApp
- *
- * Initialize the application. Your initialization method should
- * at least call the inherited method. If your application class
- * defines its own instance variables or global variables, this
- * is a good place to initialize them.
- *
- ***/
-
- CNeoDemoApp::CNeoDemoApp(void)
- #ifdef qNeoShare
- : CNeoAppShareTCL(kNeoDemoSig, kNeoDemoFileType, kExtraMasters, kRainyDayFund, kCriticalBalance, kToolboxBalance)
- #else
- : CNeoAppTCL()
- #endif
- {
- CNeoMetaClass * meta;
-
- #if defined(__TCL_DEBUG__) && !defined(TCL_USE_PP_EXCEPTIONS)
- // _gTCLBreakFailure = TRUE;
- #endif
-
- IApplication(kNeoExtraMasters, kNeoRainyDayFund, kNeoCriticalBalance, kNeoToolboxBalance);
-
- // Add CNDImage class to metaclass table
- meta = new CNeoMetaClass(kNDImageID, kNeoPersistID, "\pCNDImage");
-
- // Add CNDImagePICT class to metaclass table
- meta = new CNeoMetaClass(kNDImagePICTID, kNDImageID, "\pCNDImagePICT", CNDImagePICT::New);
-
- // Add CNDImageTIFF class to metaclass table
- meta = new CNeoMetaClass(kNDImageTIFFID, kNDImageID, "\pCNDImageTIFF", CNDImageTIFF::New);
-
- // Add CNDImageGIF class to metaclass table
- meta = new CNeoMetaClass(kNDImageGIFID, kNDImageID, "\pCNDImageGIF", CNDImageGIF::New);
-
- // Add CNDCamera class to metaclass table
- meta = new CNeoMetaClass(kNDCameraID, kNeoPersistID, "\pCNDCamera", CNDCamera::New);
-
- CNeoPersist::FCacheSize = 0x40000; // Give the object cache a quarter meg to play with.
- }
-
- /***
- * SetUpFileParameters
- *
- * In this routine, you specify the kinds of files your
- * application opens.
- *
- *
- ***/
-
- void CNeoDemoApp::SetUpFileParameters(void)
-
- {
- inherited::SetUpFileParameters(); /* Be sure to call the default method */
-
- /**
- ** sfNumTypes is the number of file types
- ** your application knows about.
- ** sfFileTypes[] is an array of file types.
- ** You can define up to 4 file types in
- ** sfFileTypes[].
- **
- **/
-
- sfNumTypes = 1;
- sfFileTypes[0] = kNeoDemoFileType; /* Neo Demo file type */
-
- /**
- ** Although it's not an instance variable,
- ** this method is a good place to set the
- ** gSignature global variable. Set this global
- ** to your application's signature. You'll use it
- ** to create a file (see CFile::CreateNew()).
- **
- **/
-
- gSignature = kNeoDemoSig; /* set application signature */
- }
-
- /***
- * createDocument
- *
- * The user chose New from the File menu.
- * In this method, you need to create a document and send it
- * a NewFile() message.
- *
- ***/
- CNeoDoc *CNeoDemoApp::createDocument(void)
- {
- CNeoDemoDoc * document = nil;
-
- NEOTRY
- {
- document = new CNeoDemoDoc(this, kNotPrintable, TRUE, FALSE);
-
- /**
- ** Send the document a NewFile() message.
- ** The document will open a window, and
- ** set up the heart of the application.
- **
- **/
-
- document->NewFile();
- }
-
- NEOCATCH
- {
- /*
- * This exception handler gets executed if a failure occurred
- * anywhere within the scope of the TRY block above. Since
- * this indicates that a new doc could not be created, we
- * check if an object had been allocated and if it has, send
- * it a unrefer message. The exception will propagate up to
- * CSwitchboard's exception handler, which handles displaying
- * an error alert.
- */
-
- if (document) {
- delete document;
- document = nil;
- }
- }
- NEOENDTRY;
-
- return document;
- }
-
- /***
- * OpenDocument
- *
- * The user chose Open… from the File menu.
- * In this method you need to create a document
- * and send it an OpenFile() message.
- *
- * The macSFReply is a good SFReply record that contains
- * the name and vRefNum of the file the user chose to
- * open.
- *
- ***/
-
- void CNeoDemoApp::OpenDocument(SFReply *macSFReply)
- {
- Boolean remote;
- long procID;
- FSSpec fsSpec;
- CNeoDemoDoc * document = nil;
-
- NEOTRY
- {
- // Our parent will check to see if this is a document we have already opened.
- // If we find the file already open by the app, then fDocument will refer to it.
- // If the file is opened but not by this app, then the parent will signal a failure.
- inherited::OpenDocument(macSFReply);
- if (fDocument)
- return;
-
- #ifdef qNeoShare
- remote = fOpeningRemote;
- #else
- remote = FALSE;
- #endif
-
- document = new CNeoDemoDoc(this, TRUE, FALSE, remote);
-
- /**
- ** Send the document an OpenFile() message.
- ** The document will open a window, open
- ** the file specified in the macSFReply record,
- ** and display it in its window.
- **
- **/
- document->OpenFile(macSFReply);
- }
-
- NEOCATCH
- {
- /*
- * This exception handler gets executed if a failure occurred
- * anywhere within the scope of the TRY block above. Since
- * this indicates that the document could not be opened, we
- * send it a unrefer message. The exception will propagate up to
- * CSwitchboard's exception handler, which handles displaying
- * an error alert.
- */
-
- if (document)
- delete document;
- }
- NEOENDTRY;
- }
-
-